<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>使用 Date 对象获得当前日期</title>
</head>
<body>
<script>
    var months = ['January', 'February', 'March', 'Aprel', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];

    var dateNow = new Date();
    var yearNow = dateNow.getFullYear();
    var monthNow = months[dateNow.getMonth()];
    var dayNow = dateNow.getDay();

    var daySuffix;
    switch (dayNow) {
        case 1:
        case 21:
        case 31:
            daySuffix = 'st';
            break;
        case 2:
        case 22:
            daySuffix = 'nd';
            break;
        case 3:
        case 23:
            daySuffix = 'rd';
            break;
        default:
            daySuffix = 'th';
            break;
    }

    document.write('It is the ' + dayNow + daySuffix + ' day');
    document.write(' in the month of ' + monthNow);
    document.write(' in the year ' + yearNow);
</script>
</body>
</html>